package com.td.client.gui;

import org.newdawn.slick.Graphics;

import com.td.core.obj.Player;
import com.td.core.obj.TDMap;
import com.td.core.obj.bullet.Bullet;
import com.td.core.obj.tower.Tower;
import com.td.core.obj.unit.Unit;

public class PlayerRenderer implements TDMap.DrawParams {
	
	public static void draw(int playerNumber, Player player, Graphics g) {
		int plx = playerNumber * BSIZE_X + BREAK - GameRenderer.getInstance().getBaseX();
		
		if(plx > TDMap.Screen.X || plx + SIZE_X < 0) return;
		
		synchronized (player) {
			for(Tower t: player.getTowers()) {
				TowerRenderer.draw(playerNumber, plx, t, g);
			}
		
			for(Unit u: player.getUnits()) {
				UnitRenderer.getInstance().draw(plx, u, g);
			}
			
			for(Bullet b: player.getBullets()) {
				BulletRenderer.draw(plx, b, g);
			}
		}
	}
}
